package com.yang.qgg_demo.common.Interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.yang.qgg_demo.utils.TokenUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

@Component
public class JwtInterceptor implements HandlerInterceptor {

//    private static final Logger logger = LoggerFactory.getLogger(JwtInterceptor.class);
//
//    @Override
//    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//        String token = request.getHeader("token");
//        if (token == null || !isValidToken(token)) {
//            logger.warn("Invalid or missing token: {}", token);
//            response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
//            return false;
//        }
//        logger.debug("Valid token found: {}", token);
//        return true; // 继续处理请求
//    }
//
//    private boolean isValidToken(String token) {
//        // 这里应该实现JWT的验证逻辑
//        // 例如：检查签名、过期时间等
//        return token.startsWith("Bearer "); // 示例验证逻辑
//    }
}